public member function
<iterator>

std::reverse_iterator::operator->

pointer operator->() const;
Dereference iterator
Returns a pointer to the element pointed to by the iterator (in order to access one of its members).

Internally, the function calls operator* and returns its address, as if implemented as:
1
2
3
pointer operator->() const {
  return &(operator*());
}

Internally, the function calls operator* and returns its address (using addressof), as if implemented as:
1
2
3
pointer operator->() const {
  return addressof(operator*());
}


The iterator shall point to some object in order to be dereferenceable.

Parameters

none

Return value

A pointer to the element pointed by the iterator.
Member type pointer is an alias of the base iterator's own pointer type.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// reverse_iterator::operator-> example
#include <iostream>     // std::cout
#include <iterator>     // std::reverse_iterator
#include <utility>      // std::make_pair
#include <map>          // std::map
#include <string>       // std::string

int main () {
  std::map<int,std::string> numbers;
  numbers.insert (std::make_pair(1,"one"));
  numbers.insert (std::make_pair(2,"two"));
  numbers.insert (std::make_pair(3,"three"));

  typedef std::map<int,std::string>::iterator map_iter;

  std::reverse_iterator<map_iter> rev_end (numbers.begin());

  std::reverse_iterator<map_iter> rev_iterator (numbers.end());

  for ( ; rev_iterator != rev_end ; ++rev_iterator )
    std::cout << rev_iterator->first << ' ' << rev_iterator->second << '\n';

  return 0;
}


Output:

3 three
2 two
1 one

Data races

The object is accessed.
The pointer returned can be used to access or modify elements.

Exception safety

Provides the same level of guarantee as the operations internally applied to the base iterator.

See also